﻿package com.views {
	import com.*;
	import com.protocols.*;
	import com.type.FunctionType;
	import com.utils.GameMouseCursor;
	import com.utils.URI;
	import com.views.interfaces.IToolbar;
	import com.views.structure.Structure;
	
	import flash.display.*;
	import flash.events.*;
	import flash.geom.*;
	import flash.utils.*;

	public class ToolbarView extends Base implements IView {

		private static var CleanUpgradeCdSign:String = "CleanUpgradeCd";

		private var _toolbar:IToolbar;

		public function ToolbarView() {
			super();
		}

		public function get width():Number {
			return (this._toolbar.content.width);
		}

		public function get height():Number {
			return (this._toolbar.content.height);
		}

		public function get content():Sprite {
			return (this._toolbar.content);
		}

		override public function get inStage():Boolean {
			return (((this._toolbar) && (this._toolbar.content.parent)));
		}

		public function init():void {
			this._toolbar = (_view.getAssetsObject("Toolbar", "Toolbar") as IToolbar);
			this._toolbar.tip = _view.tip;
			this._toolbar.goodsIconUrl = URI.goodsIconUrl;
			this._toolbar.addonsUrl = URI.addonsUrl;
			this._toolbar.init();
			this._toolbar.newFunctionBar(FunctionType.FullList, []);
//			this._view.chat.show();
			_view.addToPositionList(sign, this.reposition);
			_view.addToFrameProcessList("ToolbarUpdateMouseCursor", this.updateMouseCursor);
		}

		private function updateMouseCursor():void {
			GameMouseCursor.updateCursorXY();
		}

		public function show():void {
			this._toolbar.content.visible = true;
		}

		public function hide():void {
			this._toolbar.content.visible = false;
		}

		public function close():void {
			this.clear();
			if (this._toolbar.content.parent) {
				this._toolbar.content.parent.removeChild(this._toolbar.content);
			}
			;
		}

		public function clear():void {
//			_data.cancelPatch(Mod_Player_Base.receive_player_delay_notify_message);
//			_data.cancelPatch(Mod_Notify_Base.mission_award);
//			_data.cancelPatch(Mod_Notify_Base.pk_award);
//			_data.cancelPatch(Mod_Friend_Base.notify_online_state);
//			_data.cancelPatch(Mod_Friend_Base.notify_message_count);
//			_data.cancelPatch(Mod_CampWar_Base.notify);
//			_data.cancelPatch(Mod_HeroesWar_Base.notify);
//			_data.cancelPatch(Mod_Notify_Base.role_num_notify);
//			_data.cancelPatch(Mod_Notify_Base.new_research_notify);
//			_data.cancelPatch(Mod_Notify_Base.new_partners_notify);
			this._toolbar.clear();
		}

		public function reposition():void {
			if (this.inStage == true) {
				this._toolbar.reposition(Structure.minStageWidth, Structure.minStageHeight, Structure.maxStageWidth, Structure.maxStageHeight, Structure.stageClip);
			}
			;
			Tip.offset = Structure.stageOffset;
			_structure.reposition();
			_view.reposition();
//			_view.achievementComplete.reposition(false);
//			_view.activities.reposition(false);
//			_view.alert.reposition();
//			_view.chat.reposition(false);
//			_view.delayMessage.reposition(false);
//            _view.dreamSectionWar.reposition(false);
//            _view.dujieWar.reposition(false);
//            _view.factionWar.reposition(false);
//			_view.fate.reposition(false);
//			_view.friendMessage.reposition(false);
//            _view.getPeachWar.reposition(false);
//			_view.guide.reposition();
//            _view.haloRoleWar.reposition(false);
//            _view.inCampWar.reposition(false);
			_view.initLoading.reposition(false);
//			_view.lodge.reposition(false);
//            _view.miniFactionWar.reposition(false);
//			_view.missionFailedTips.reposition(false);
//			_view.multiWar.reposition(false);
//            _view.pkWar.reposition(false);
//			_view.processTip.reposition(false);
//            _view.sealSoul.reposition(false);
//			_view.sendFlower.reposition(false);
//            _view.sportWar.reposition(false);
//			_view.superSport.reposition(false);
//			_view.superSportWar.reposition(false);
//			_view.takeBibleRoad.reposition(false);
//			_view.takeBibleWar.reposition(false);
//			_view.tip2.reposition();
//            _view.towerWar.reposition(false);
//			_view.war.reposition(false);
//			_view.world.reposition(false);
//            _view.worldBossWar.reposition(false);
//			_view.worldNotice.reposition(false);
//            _view.rollCake.reposition(false);
//            _view.factionRollCake.reposition(false);
//            _view.zodiacWar.reposition(false);
//			_view.studyStunt.reposition(false);
//			_view.activitiesShow.reposition();
//			_view.sideBar.reposition(false);
		}

		public function repositionInTown():void {
//			if (((_view.townMap.inStage) && ((true == this._firstInTown)))) {
//				this._firstInTown = false;
//				this.reposition();
//			}
//			;
		}

	}
}
